package edu.mit.media.fv.components
{
	import flash.display.*;
	import flash.events.*;
	import flash.filters.*;

	public class FVIconButton2 extends Sprite
	{
		private var filter:BevelFilter = new BevelFilter();
			
		private var infilter:BevelFilter = new BevelFilter(4,45,0,1,0xFFFFFF,1,4,4,1,1, BitmapFilterType.INNER);
		private var button:Sprite;
		private var icon:DisplayObject;
		
		public function FVIconButton2(o:DisplayObject)
		{
			super();
			
			button = new Sprite();
			button.graphics.beginFill(0x888888, 1.0);
			//r.graphics.lineStyle(1,0xFFFFFF,0.7,true);
			button.graphics.drawRoundRect(0,0,100,100,15,15);
			button.graphics.endFill();
			this.addChild(button);
			
			this.icon = o;
			icon.width = 50;
			icon.height = 50;
			icon.x = 25;
			icon.y = 25;
			this.addChild(this.icon);
			
			button.filters = [filter];
			icon.filters = [infilter];
			
			this.addEventListener(MouseEvent.MOUSE_UP, processMouseUp);
			this.addEventListener(MouseEvent.MOUSE_OUT, processMouseOut);
			this.addEventListener(MouseEvent.MOUSE_DOWN, processMouseDown);
		}
		private var isPressed:Boolean = false;
		private function processMouseUp(event:MouseEvent):void{
			this.isPressed = false;
			button.filters = [filter];
		}
		private function processMouseDown(event:MouseEvent):void{
			this.isPressed = true;
			button.filters = [infilter];
		}
		private function processMouseOut(event:MouseEvent):void{
			this.isPressed = false;
			button.filters = [filter];
		}
		
	}
}